package cn.stronglink.asset.terminal.bjc.repair.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.stronglink.asset.terminal.bjc.repair.service.RepairApiService;
import cn.stronglink.asset.terminal.bjc.repair.vo.RepairApiVo;
import cn.stronglink.suite.core.base.AbstractController;

@Controller
@RequestMapping(value = "/bjc/repairApi")
public class RePairApiController extends AbstractController{
	
	@Autowired
	private RepairApiService repairApiService;
	
	/**
	 * 确认维修
	 * @param modelMap
	 * @param request
	 * @param response
	 * @param repair
	 * @return
	 */
	@RequestMapping(value = "doRepair")
	public ResponseEntity<ModelMap> creatRepair(ModelMap modelMap, HttpServletRequest request,
			HttpServletResponse response,@RequestBody RepairApiVo repair) {	
		repairApiService.doRepair(repair);
		return setSuccessModelMap(modelMap, null);
	}	
	
	/**
	 * 查询列表
	 * @param modelMap
	 * @param request
	 * @param response
	 * @param params
	 * @return
	 */
	@RequestMapping(value = "qryRepairList")
	public ResponseEntity<ModelMap> qryRepairList(ModelMap modelMap, HttpServletRequest request,
			HttpServletResponse response,@RequestBody Map<String,Object> params) {	
		List<RepairApiVo> list = repairApiService.qryRepairList(params);
		return setSuccessModelMap(modelMap, list);
	}	
	
	/**
	 * 删除维修单
	 * @param modelMap
	 * @param request
	 * @param response
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "removeRepair")
	public ResponseEntity<ModelMap> remove(ModelMap modelMap, HttpServletRequest request,
			HttpServletResponse response,@RequestBody Long id) {
		repairApiService.remove(id);
		return setSuccessModelMap(modelMap, null);
	}
}
